<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function fillDate(arr) {
        console.log('arr:', arr)
        const date = new Date(arr[0].date);
        const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
        const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

        console.log(firstDay, lastDay)

        const startDate = firstDay.toString().substring(0, 10)
        const endDate = lastDay.toString().substring(0, 10)

        const result = [];
        let allDays = []
        for (let d = firstDay; d <= lastDay; d.setDate(d.getDate() + 1)) {

            const date = new Date(d);
            const day = date.getDate().toString().padStart(2, '0');
            const year = date.getFullYear();
            const month = (date.getMonth() + 1).toString().padStart(2, '0');

            const q = `${year}-${month}-${day}`;
            allDays.push(q)

            const existingItem = arr.find(item => item.date === q);

            if (existingItem) {
                result.push(existingItem);
            } else {
                result.push({date: q, value: 0});
            }
        }

        console.log('allDays:', allDays)
        return result;
    }


    let arr = [

        {date: '2023-05-05', value: 200, id: 2},
        {date: '2023-05-07', value: 220, id: 3},
    ]

    console.log(fillDate(arr))

</script>
</body>
</html>
